<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form" action="../submituser" method="get">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red"></span>登录名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="username" name="username" required="" lay-verify="required"
                  autocomplete="off"  class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="" id="xusername">将会成为您唯一的登入名</span>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class=""></span>手机
              </label>
              <div class="layui-input-inline">
                  <input type="text"  id="phone" name="phone" required="" lay-verify="phone"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="" id="xphone"></span>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">
                  <span class="">性别</span>
              </label>
              <div class="layui-input-inline">
                 <!--  <input type="text"  id="L_email" name="email" required="" lay-verify="email"
                  autocomplete="off" class="layui-input"> -->
                  	<input type="radio" value="男" name="sex">男
                  	<input type="radio" value="女" name="sex">女
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class=""></span>
              </div>
          </div>
             <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">
                  <span class="">地址</span>
              </label>
              <div class="layui-input-inline">
                 <!--  <input type="text"  id="L_email" name="email" required="" lay-verify="email"
                  autocomplete="off" class="layui-input"> -->
                  	<input type="text"  id="address" name="address" required="" lay-verify="email"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="" id ="xaddress"></span>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_pass" class="layui-form-label">
                  <span class="">密码</span>
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="pass" name="pass" required="" lay-verify="pass"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux" >
                  <span class="" id="xpass">至少6个字符</span>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="srepass" class="layui-form-label">
                  <span class=""></span>确认密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="repass" name="repass" required="" lay-verify="repass"
                  autocomplete="off" class="layui-input">
              </div>
               <div class="layui-form-mid layui-word-aux" id="xrpass">
                  <span class="" id="xrpass"></span>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
            <input type="submit"class="layui-btn" lay-filter="add" value="增加" id="tijiao">
          </div>
      </form>
    </div>
    <script>
    //验证用户名是否在数据库中重复 ，制定用户名的规则
 	$(function(){
 		$("#username").on("blur",function(){
 			
 			var name =$("#username").val();
 			var reg =/^[a-zA-Z0-9]{6,12}$/
 			var b=reg.test(name);
 			if(b){
 				$.get({
 					url:"../useradd", 
 					data:{"username":name},
 				
 					success:function(result){
 						if(result=="true"){
 							$("#xusername").html("√");
 						}else{
 							$("#xusername").html("用户名重复");
 							
 						}
 					}
 				})
 			}else{
 				$("#xusername").html("输入格式不对！")
 			}
 		})
 	})
 
 //验证手机号
 $(function(){
	 $("#phone").on("blur",function(){
		 var pattern = /^1[34578]\d{9}$/;
		 var phone =$("#phone").val();
		 var b =pattern.test(phone);
		 if(b){
			 $("#xphone").html("√");
		 }else{
			 $("#xphone").html("电话格式不对");
		 }
	 })
 })
 //验证邮箱格式
$(function(){
	$("#address").on("blur",function(){
		var address=$("#address").val();
		if(address !== null){
			$("#xaddress").html("√");
		}else{
			$("#xaddress").html("请输入地址");
		}
	})
})
 
 //定义密码的输入格式
 $(function(){
	 $("#pass").on("blur",function(){
		 var pass =$("#pass").val();
		 var reg=/^[a-zA-Z0-9]{6,}$/
		 var b =reg.test(pass);
		 if(b){
			 $("#xpass").html("√");  
		 }else{
			 $("#xpass").html("输入格式不对");
		 }
	 })
 })

 
 
 //定义密码两次密码是否输入一致
 $(function(){
	 $("#repass").on("blur",function(){
		 
		 var pass =  $("#pass").val();
		 var rpass = $("#repass").val();
		 if(pass==rpass){
				 $("#xrpass").html("√")
	     }else{
				 $("#xrpass").html("两次密码不一致");
		}
		 
	 })
 })
    
   $(function(){
	   $("#tijiao").on("click",function(){
		   window.opener.location="../userlist";
	   })
   })
 
 </script>
   <!--      layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
          //自定义验证规则
          form.verify({
            nikename: function(value){
              if(value.length < 5){
                return '昵称至少得5个字符啊';
              }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
          });

          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
            //发异步，把数据提交给php
            layer.alert("增加成功", {icon: 6},function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
            return false;
          });
          
          
        });
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script> -->
</body>
</html>